<?php
/**
 * Created by PhpStorm.
 * User: kkw
 * Date: 2019/1/28
 * Time: 14:51
 */

namespace kkw\wantbuy\response;
use kkw\user\Util;
use kkw\wantbuy\table\WantBuyTable;
use suda\core\Request;
use suda\core\Response;

class DeleteWantResponse extends  Response
{
    public function onRequest(Request $request)
    {
        Util::printHeader();
        $json = Request::json();
        $id= $json['id'];
        // 实例化求购信息表
        $want_buy_table = new WantBuyTable();
        // 查询数据
        try {
            $want_buy_table->delete(['id'=>$id]);
        } catch (\suda\exception\SQLException $e) {
            $this->json(['code'=>$e->getCode(), 'message'=>'删除数据失败']);
        }
        $this->json([
            'code'=> 0 ,
            'message'=> '删除信息成功'
        ]);
    }
}